1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| //日期没有处理前 @GetMapping("/demo") public R test(){ //五分钟之前(和北京时间差8小时) Instant now = Instant.now().minus(Duration.ofMinutes(5)); return R.ok().data("msg","测试demo").data("now",new Date()).data("date",now); } //输出结果 {"code":0,"msg":"成功","data":{"msg":"测试demo","date":"2022-11-18T08:07:39.330Z","now":"2022-11-18T16:07:39.330+0800"}} //配置文件加入 spring: jackson: date-format: yyyy-MM-dd HH:mm:ss time-zone: GMT+8 //输出结果 {"code":0,"msg":"成功","data":{"msg":"测试demo","date":"2022-11-18T08:16:37.075Z","now":"2022-11-18 16:16:37"}}
{"code":0,"msg":"成功","data":{"aa":11,"aa1":112}}
|